home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / memory.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-12  |  1.6 KB  |  65 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: memory.h,v 1.2 1996/08/01 17:41:27 digulla Exp $
  4.     $Log: memory.h,v $
  5.     Revision 1.2  1996/08/01 17:41:27  digulla
  6.     Added standard header for all files
  7.  
  8.     Desc:
  9.     Lang:
  10. */
  11. #ifndef _MEMORY_H_
  12. #define _MEMORY_H_
  13. #include <exec/lists.h>
  14. #include <stddef.h>
  15.  
  16. #define RTPOTx4(a)      ((a)>2?4:(a)>1?2:1)
  17.  
  18. #define RTPOTx10(a)     ((a)>=4?RTPOTx4(((a)+3)/4)*4:RTPOTx4(a))
  19.  
  20. #define RTPOTx100(a)    \
  21. ((a)>=0x10?RTPOTx10(((a)+0xf)/0x10)*0x10:RTPOTx10(a))
  22.  
  23. #define RTPOTx10000(a)  \
  24. ((a)>=0x100?RTPOTx100(((a)+0xff)/0x100)*0x100:RTPOTx100(a))
  25.  
  26. #define RTPOTx100000000(a)      \
  27. ((a)>=0x10000?RTPOTx10000(((a)+0xffff)/0x10000)*0x10000:RTPOTx10000(a))
  28.  
  29. #define ROUNDUP_TO_POWER_OF_TWO(a)      RTPOTx100000000(a)
  30.  
  31. /* Some defines for the memory handling functions. */
  32.  
  33. /* This is for the alignment of memchunk structures. */
  34. #define MEMCHUNK_TOTAL    \
  35. ROUNDUP_TO_POWER_OF_TWO(DOUBLEALIGN>sizeof(struct MemChunk)? \
  36. DOUBLEALIGN:sizeof(struct MemChunk))
  37.  
  38. /* This allows to take the end of the MemHeader as the first MemChunk. */
  39. #define MEMHEADER_TOTAL \
  40. ((sizeof(struct MemHeader)+MEMCHUNK_TOTAL-1)&~(MEMCHUNK_TOTAL-1))
  41.  
  42. /* This is the extra memory needed by AllocVec() */
  43. #define ALLOCVEC_TOTAL \
  44. (DOUBLEALIGN>sizeof(ULONG)?DOUBLEALIGN:sizeof(ULONG))
  45.  
  46. struct Pool /* Private Pool structure */
  47. {
  48.     struct MinList PuddleList;
  49.     struct MinList BlockList;
  50.     ULONG Requirements;
  51.     ULONG PuddleSize;
  52.     ULONG ThreshSize;
  53. };
  54.  
  55. struct Block
  56. {
  57.     struct MinNode Node;
  58.     ULONG Size;
  59. };
  60.  
  61. #define BLOCK_TOTAL \
  62. ((sizeof(struct Block)+DOUBLEALIGN-1)&~(DOUBLEALIGN-1))
  63.  
  64. #endif
  65.